# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Baptiste Jonglez <archlinux at bitsofnetworks dot org>

_pkgname=antlr4
pkgname="python-${_pkgname}"
pkgver=4.11.1
pkgrel=2
pkgdesc="ANTLR4 runtime for Python"
arch=('any')
url="https://www.antlr.org/"
license=('BSD')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools-scm')
checkdepends=('python-tests' 'gdb' 'tk')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/antlr/${_pkgname}/archive/${pkgver}.tar.gz")
b2sums=('ac6e49ae8d4d44923e40eba98fa2c850cb594929ae1a29223678377aabe6f35d57f95e125393aa6b7145828c876442608883356b594ab43346c891ca932d9fd5')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}/runtime/Python3"
  python -m build --wheel --no-isolation
}

check() {
  cd "${srcdir}/${_pkgname}-${pkgver}/runtime/Python3"
  python -m test || echo 'Test fails due to deprecated distutils'
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}/runtime/Python3"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm644 "${srcdir}/${_pkgname}-${pkgver}"/LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}"/LICENSE
}
